package edu.suda.basic.sigar;

import org.hyperic.sigar.Mem;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.Swap;

import com.thoughtworks.xstream.XStream;

public class Memory
{
	private Mem		mem;
	private Swap	swap;

	public Memory()
	{
	}

	public void populate(Sigar sigar) throws SigarException
	{
		mem = sigar.getMem();
		swap = sigar.getSwap();
	}

	public static Memory gather(Sigar sigar) throws SigarException
	{
		Memory data = new Memory();
		data.populate(sigar);
		return data;
	}

	public static void main(String[] args) throws Exception
	{
		Sigar sigar = new Sigar();
		Memory memData = Memory.gather(sigar);
		XStream xstream = new XStream();
		xstream.alias("MemData", Memory.class);
		System.out.println(xstream.toXML(memData));
	}

}
